//
//  ConfirmOrderCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 16/6/21.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "ConfirmOrderCell.h"

@implementation ConfirmOrderCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle: style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.orderImg = [[UIImageView alloc] init];
    _orderImg.image = [UIImage imageNamed:@"headgao.jpg"];
    [self.contentView addSubview:_orderImg];
    
    self.orderName = [[UILabel alloc] init];
    _orderName.font = [UIFont systemFontOfSize:14];
    _orderName.text = @"高俊熙穿着磁性文胸恒定静磁场";
    _orderName.numberOfLines = 0;
    [self.contentView addSubview:_orderName];
    
    self.orderColorSize = [[UILabel alloc] init];
    _orderColorSize.font = [UIFont systemFontOfSize:13];
    _orderColorSize.text = @"颜色 : 白色  尺码 : XL";
    _orderColorSize.numberOfLines = 2;
    _orderColorSize.textColor = [UIColor grayColor];
    [self.contentView addSubview:_orderColorSize];
    
    self.orderNumber = [[UILabel alloc] init];
    _orderNumber.font = [UIFont systemFontOfSize:14];
    _orderNumber.text = @"x1";
    _orderNumber.textColor = [UIColor grayColor];
    _orderNumber.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_orderNumber];
    
    self.orderPrice = [[UILabel alloc] init];
    _orderPrice.font = [UIFont systemFontOfSize:14];
    _orderPrice.text = @"¥ 200积分";
    _orderPrice.textColor = DEFAULT_COLOR;
    _orderPrice.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:_orderPrice];

    CGFloat Margin = 10;
    CGFloat leftM = 15;
    [_orderImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.mas_left).offset(leftM);
        make.width.height.mas_equalTo(HEIGHT/14);
        make.top.equalTo(self.mas_top).offset(leftM);
    }];
    
    [_orderName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_orderImg.mas_right).offset(Margin);
        make.top.equalTo(_orderImg.mas_top);
        make.right.equalTo(self.mas_right).with.offset(-Margin);
        make.height.mas_equalTo(Margin * 4);
    }];
    
    [_orderName sizeToFit];
    
    [_orderColorSize mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_orderName.mas_left);
        make.top.equalTo(_orderName.mas_bottom).offset(-3);
        make.width.mas_equalTo(WIDTH-_orderImg.width-Margin * 14);
        make.height.mas_equalTo(Margin * 4);
    }];
    
    [_orderNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.mas_right).offset(-leftM);
        make.top.equalTo(_orderName.mas_bottom).offset(5);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(Margin);
    }];
    
    [_orderPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.right.equalTo(self.mas_right).offset(-leftM);
        make.top.equalTo(_orderNumber.mas_bottom).offset(Margin);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(12);
    }];
}

@end
